package de.jenseins.utils.propertytranslator.service;

import java.util.ArrayList;
import java.util.List;

import com.google.api.translate.Language;

public class LanguageManager {

	private static List<Language> excludedLanguages = new ArrayList<Language>();

	static {
		excludedLanguages.add(Language.AUTO_DETECT);
	}

	public static String[] getLanguages() {
		Language[] languages = Language.values();
		String[] result = new String[languages.length - excludedLanguages.size()];
		int i = 0;
		for (Language l : languages) {
			if (!excludedLanguages.contains(l)) {
				result[i++] = l.name();
			}
		}
		return result;
	}

	public static Language getLanguage(String name) {
		Language result = Language.valueOf(name);
		return result;
	}

	public static Language[] getLanguages(String[] names) {
		Language[] result = new Language[names.length];
		int i = 0;
		for (String name : names) {
			result[i++] = LanguageManager.getLanguage(name);
		}
		return result;
	}

}
